#include "getintnetdata.h"
#include "ckdialog.h"


GetIntnetData::GetIntnetData()
{

}

void GetIntnetData::run()
{
    //重写run函数
    QString str_wq3=getHtml("https://gitee.com/CharlinChen/GISChoose/raw/master/gacha_data/WQ_3.txt");
    WQ3=str_wq3.split(" ");
    QString str_wq4=getHtml("https://gitee.com/CharlinChen/GISChoose/raw/master/gacha_data/WQ_4.txt");
    WQ4=str_wq4.split(" ");
    QString str_wq5=getHtml("https://gitee.com/CharlinChen/GISChoose/raw/master/gacha_data/WQ_5.txt");
    WQ5=str_wq5.split(" ");
    QString str_js4=getHtml("https://gitee.com/CharlinChen/GISChoose/raw/master/gacha_data/JS_4.txt");
    JS4=str_js4.split(" ");
    QString str_js5=getHtml("https://gitee.com/CharlinChen/GISChoose/raw/master/gacha_data/JS_5.txt");
    JS5=str_js5.split(" ");
    QString str_AD=getHtml("https://gitee.com/CharlinChen/GISChoose/raw/master/gacha_data/AD.txt");
    AD=str_AD.split(" ");
    //qDebug()<<WQ3<< WQ4<<WQ5<<JS4<<JS5;
    if(WQ3[0]!="")emit dataGet();//发送信号，告知数据接收完毕
    //emit dataGet();//发送信号，告知数据接收完毕

}

QString GetIntnetData::getHtml(QString URLSTR)
{
        QUrl url(URLSTR);
        QNetworkAccessManager manager;
        QEventLoop loop;
        QNetworkReply *reply = manager.get(QNetworkRequest(url));
        QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
        loop.exec();
        QString code = reply->readAll();
        return code;
}
